<?php

namespace app\admin\validate;


class CompanyValidate extends BaseValidate
{
    public function __construct()
    {
        $rule = [
            "name"                  => 'require|max:50',
            'abbreviation'          => 'require|max:10',
            "real_name"             => 'require|max:10',
            "mobile"                => 'require|max:11',
            "province_id"           => 'require|integer',
            "city_id"               => 'require|integer',
            "area_id"               => 'require|integer',
            "address"               => 'require|max:50',
            "logo"                  => 'require|max:255',
            'user_name'             => 'require|length:6,15|unique:company_user',
            'password'              => 'require|length:6,15',
            'password_confirmation' => 'require|confirm:password',
        ];

        $message = [
            "name.require"                  => '公司名称不能为空',
            "name.max"                      => '公司名称长度不能超过50个字符',
            "abbreviation.require"          => '公司简称不能为空',
            "abbreviation.max"              => '公司简称长度不能超过10个字符',
            "real_name.require"             => '负责人姓名不能为空',
            "real_name.max"                 => '负责人姓名长度不能超过10个字符',
            "mobile.require"                => '负责人手机号不能为空',
            "mobile.max"                    => '负责人手机号长度不能超过11个字符',
            "province_id.require"           => '省Id不能为空',
            "province_id.integer"           => '省Id必须为整数',
            "city_id.require"               => '市Id不能为空',
            "city_id.integer"               => '市Id必须为整数',
            "area_id.require"               => '区Id不能为空',
            "area_id.integer"               => '区Id必须为整数',
            "address.require"               => '公司地址不能为空',
            "address.max"                   => '公司地址长度不能超过50个字符',
            "logo.require"                  => '公司logo不能为空',
            "logo.max"                      => '公司logo长度不能超过255个字符',
            'user_name'                     => '用户名不能为空',
            'user_name.length'              => '用户名长度必须在6到15个字符之间',
            'user_name.unique'              => '用户名已存在',
            'password'                      => '密码不能为空',
            'password.length'               => '密码长度必须在6到15个字符之间',
            'password_confirmation.confirm' => '确认密码不正确',
        ];

        $scene = [
            'add'  => ['name','real_name', 'mobile', 'province_id', 'city_id', 'area_id', 'address', 'logo','user_name','password','password_confirmation'],
        ];
        parent::__construct($rule, $message, $scene);
    }
}